#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    vector<vector<int>> restoreMatrix(vector<int> &rowSum, vector<int> &colSum)
    {
        int x = rowSum.size(), y = colSum.size();
        vector<vector<int>> ret(x, vector<int>(y, 0));
        for (int i = 0; i < x; ++i)
        {
            for (int j = 0; j < y; ++j)
            {
                ret[i][j] = min(rowSum[i], colSum[j]);
                rowSum[i] -= ret[i][j];
                colSum[j] -= ret[i][j];
            }
        }
        return ret;
    }
};